home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / aclocal-1.5 / python.m4 < prev    next >
Encoding:
M4 Source File  |  2005-10-16  |  4.3 KB  |  130 lines

  1. ## ------------------------
  2. ## Python file handling
  3. ## From Andrew Dalke
  4. ## Updated by James Henstridge
  5. ## ------------------------
  6.  
  7. # AM_PATH_PYTHON([MINIMUM-VERSION])
  8.  
  9. # Adds support for distributing Python modules and packages.  To
  10. # install modules, copy them to $(pythondir), using the python_PYTHON
  11. # automake variable.  To install a package with the same name as the
  12. # automake package, install to $(pkgpythondir), or use the
  13. # pkgpython_PYTHON automake variable.
  14.  
  15. # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
  16. # locations to install python extension modules (shared libraries).
  17. # Another macro is required to find the appropriate flags to compile
  18. # extension modules.
  19.  
  20. # If your package is configured with a different prefix to python,
  21. # users will have to add the install directory to the PYTHONPATH
  22. # environment variable, or create a .pth file (see the python
  23. # documentation for details).
  24.  
  25. # If the MINIUMUM-VERSION argument is passed, AM_PATH_PYTHON will
  26. # cause an error if the version of python installed on the system
  27. # doesn't meet the requirement.  MINIMUM-VERSION should consist of
  28. # numbers and dots only.
  29.  
  30.  
  31. AC_DEFUN([AM_PATH_PYTHON],
  32.  [
  33.   dnl Find a version of Python.  I could check for python versions 1.4
  34.   dnl or earlier, but the default installation locations changed from
  35.   dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
  36.   dnl in 1.5, and I don't want to maintain that logic.
  37.  
  38.   AC_PATH_PROG(PYTHON, python python2.1 python2.0 python1.6 python1.5)
  39.  
  40.   dnl should we do the version check?
  41.   ifelse([$1],[],,[
  42.     AC_MSG_CHECKING(if Python version >= $1)
  43.     changequote(<<, >>)dnl
  44.     prog="
  45. import sys, string
  46. minver = '$1'
  47. pyver = string.split(sys.version)[0]  # first word is version string
  48. # split strings by '.' and convert to numeric
  49. minver = map(string.atoi, string.split(minver, '.'))
  50. pyver = map(string.atoi, string.split(pyver, '.'))
  51. # we can now do comparisons on the two lists:
  52. if pyver >= minver:
  53.     sys.exit(0)
  54. else:
  55.     sys.exit(1)"
  56.     changequote([, ])dnl
  57.     if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
  58.     then
  59.       AC_MSG_RESULT(okay)
  60.     else
  61.       AC_MSG_ERROR(too old)
  62.     fi
  63.   ])
  64.  
  65.   AC_MSG_CHECKING([local Python configuration])
  66.  
  67.   dnl Query Python for its version number.  Getting [:3] seems to be
  68.   dnl the best way to do this; it's what "site.py" does in the standard
  69.   dnl library.  Need to change quote character because of [:3]
  70.  
  71.   AC_SUBST(PYTHON_VERSION)
  72.   changequote(<<, >>)dnl
  73.   PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
  74.   changequote([, ])dnl
  75.  
  76.  
  77.   dnl Use the values of $prefix and $exec_prefix for the corresponding
  78.   dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX.  These are made
  79.   dnl distinct variables so they can be overridden if need be.  However,
  80.   dnl general consensus is that you shouldn't need this ability.
  81.  
  82.   AC_SUBST(PYTHON_PREFIX)
  83.   PYTHON_PREFIX='${prefix}'
  84.  
  85.   AC_SUBST(PYTHON_EXEC_PREFIX)
  86.   PYTHON_EXEC_PREFIX='${exec_prefix}'
  87.  
  88.   dnl At times (like when building shared libraries) you may want
  89.   dnl to know which OS platform Python thinks this is.
  90.  
  91.   AC_SUBST(PYTHON_PLATFORM)
  92.   PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
  93.  
  94.  
  95.   dnl Set up 4 directories:
  96.  
  97.   dnl pythondir -- where to install python scripts.  This is the
  98.   dnl   site-packages directory, not the python standard library
  99.   dnl   directory like in previous automake betas.  This behaviour
  100.   dnl   is more consistent with lispdir.m4 for example.
  101.   dnl
  102.   dnl Also, if the package prefix isn't the same as python's prefix,
  103.   dnl then the old $(pythondir) was pretty useless.
  104.  
  105.   AC_SUBST(pythondir)
  106.   pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
  107.  
  108.   dnl pkgpythondir -- $PACKAGE directory under pythondir.  Was
  109.   dnl   PYTHON_SITE_PACKAGE in previous betas, but this naming is
  110.   dnl   more consistent with the rest of automake.
  111.   dnl   Maybe this should be put in python.am?
  112.  
  113.   AC_SUBST(pkgpythondir)
  114.   pkgpythondir=\${pythondir}/$PACKAGE
  115.  
  116.   dnl pyexecdir -- directory for installing python extension modules
  117.   dnl   (shared libraries)  Was PYTHON_SITE_EXEC in previous betas.
  118.  
  119.   AC_SUBST(pyexecdir)
  120.   pyexecdir=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages
  121.  
  122.   dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
  123.   dnl   Maybe this should be put in python.am?
  124.  
  125.   AC_SUBST(pkgpyexecdir)
  126.   pkgpyexecdir=\${pyexecdir}/$PACKAGE
  127.  
  128.   AC_MSG_RESULT([looks good])
  129. ])
  130.